﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RCREEE.Library.Entities
{
    public class CustomSiteMapNode
    {

        #region Private fields

        private int _siteMapNodeId;
        private int _level;

        private string _url;

        private TinyItem _title;
        private TinyItem _entity;
        private Item _titleItem;
        private Item _entityItem;
        private CustomSiteMapNode _parentSiteMapNode;
        private List<CustomSiteMapNode> _nestedNodes;
        private List<SitemapNodeContent> _sitemapNodeContents;
        private int _entityTypeId;
        private bool _isContentNode;

        private SitemapNodeContent _englishContent;
        private SitemapNodeContent _arabicContent;
        private SitemapNodeContent _frenchContent;

        #endregion

        #region Public properties
        public int SiteMapNodeId
        {
            get { return _siteMapNodeId; }
            set { _siteMapNodeId = value; }
        }

        public string Url
        {
            get { return _url; }
            set { _url = value; }
        }

        public CustomSiteMapNode ParentSiteMapNode
        {
            get { return _parentSiteMapNode; }
            set { _parentSiteMapNode = value; }
        }

        public int ParentId { get; set; }

        public TinyItem Title
        {
            get { return _title; }
            set { _title = value; }
        }

        public TinyItem Entity
        {
            get { return _entity; }
            set { _entity = value; }
        }

        public int Level
        {
            get { return _level; }
            set { _level = value; }
        }

        public List<CustomSiteMapNode> NestedNodes
        {
            get { return _nestedNodes; }
            set { _nestedNodes = value; }
        }

        public Item TitleItem
        {
            get { return _titleItem; }
            set { _titleItem = value; }
        }

        public Item EntityItem
        {
            get { return _entityItem; }
            set { _entityItem = value; }
        }

        public int EntityTypeId
        {
            get { return _entityTypeId; }
            set { _entityTypeId = value; }
        }

        public List<SitemapNodeContent> SitemapNodeContents
        {
            get { return _sitemapNodeContents; }
            set { _sitemapNodeContents = value; }
        }

        public bool IsContentNode
        {
            get { return _isContentNode; }
            set { _isContentNode = value; }
        }

        public SitemapNodeContent EnglishContent
        {
            get { return SitemapNodeContents.FirstOrDefault(content => content.LanguageCode == (int) LanguagesEnum.English); }
        }

        public SitemapNodeContent ArabicContent
        {
            get { return SitemapNodeContents.FirstOrDefault(content => content.LanguageCode == (int)LanguagesEnum.Arabic); }
        }

        public SitemapNodeContent FrenchContent
        {
            get { return SitemapNodeContents.FirstOrDefault(content => content.LanguageCode == (int)LanguagesEnum.French); }
        }

        #endregion

        #region Constractor
        public CustomSiteMapNode()
        {
            NestedNodes = new List<CustomSiteMapNode>();
            SitemapNodeContents = new List<SitemapNodeContent>();
            TitleItem = new Item();
            EntityItem = new Item();
        }
        #endregion
    }
}
